﻿// Main class, (c)2010 Knihovnik
// This file is licensed under LGPL license, see more at http://www.gnu.org/licenses/lgpl.html
namespace FacebookChat
{

	#region Usings

	using System;
	using System.Windows.Forms;
	using System.Globalization;
	using System.Threading;
	using vKapse.Common;
	
	#endregion

	static class Program
	{
		
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main()
		{
			Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
			Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
			if (!string.IsNullOrEmpty(Properties.Settings.Default.ForceCulture))
			{
				try
				{
					CultureInfo cInfo = CultureInfo.GetCultureInfo(Properties.Settings.Default.ForceCulture);
					Thread.CurrentThread.CurrentCulture =
						Thread.CurrentThread.CurrentUICulture = cInfo;
				}
				catch(ArgumentException)
				{
					Thread.CurrentThread.CurrentCulture =
						Thread.CurrentThread.CurrentUICulture = CultureInfo.CurrentCulture;
				}
			}
			Application.EnableVisualStyles();
			Application.SetCompatibleTextRenderingDefault(false);
			Application.Run(new RosterForm());
			Application.ThreadException -= new ThreadExceptionEventHandler(Application_ThreadException);
		}

		static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
		{
			ExceptionView.Show(e.Exception);
		}
	}
}
